package com.changcheng.project.oper_info.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.changcheng.framework.aspectj.lang.annotation.Log;
import com.changcheng.framework.aspectj.lang.enums.BusinessType;
import com.changcheng.project.oper_info.domain.AOperInfo;
import com.changcheng.project.oper_info.service.IAOperInfoService;
import com.changcheng.framework.web.controller.BaseController;
import com.changcheng.framework.web.domain.AjaxResult;
import com.changcheng.common.utils.poi.ExcelUtil;
import com.changcheng.framework.web.page.TableDataInfo;

/**
 * 操作员信息Controller
 * 
 * @author dazhi
 * @date 2020-11-02
 */
@Controller
@RequestMapping("/operinfo/oper_info")
public class AOperInfoController extends BaseController
{
    private String prefix = "operinfo/oper_info";

    @Autowired
    private IAOperInfoService aOperInfoService;

    @RequiresPermissions("operinfo:oper_info:view")
    @GetMapping()
    public String oper_info()
    {
        return prefix + "/oper_info";
    }

    /**
     * 查询操作员信息列表
     */
    @RequiresPermissions("operinfo:oper_info:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AOperInfo aOperInfo)
    {
        startPage();
        List<AOperInfo> list = aOperInfoService.selectAOperInfoList(aOperInfo);
        return getDataTable(list);
    }

    /**
     * 导出操作员信息列表
     */
    @RequiresPermissions("operinfo:oper_info:export")
    @Log(title = "操作员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AOperInfo aOperInfo)
    {
        List<AOperInfo> list = aOperInfoService.selectAOperInfoList(aOperInfo);
        ExcelUtil<AOperInfo> util = new ExcelUtil<AOperInfo>(AOperInfo.class);
        return util.exportExcel(list, "oper_info");
    }

    /**
     * 新增操作员信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存操作员信息
     */
    @RequiresPermissions("operinfo:oper_info:add")
    @Log(title = "操作员信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AOperInfo aOperInfo)
    {
        return toAjax(aOperInfoService.insertAOperInfo(aOperInfo));
    }

    /**
     * 修改操作员信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AOperInfo aOperInfo = aOperInfoService.selectAOperInfoById(id);
        mmap.put("aOperInfo", aOperInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存操作员信息
     */
    @RequiresPermissions("operinfo:oper_info:edit")
    @Log(title = "操作员信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AOperInfo aOperInfo)
    {
        return toAjax(aOperInfoService.updateAOperInfo(aOperInfo));
    }

    /**
     * 删除操作员信息
     */
    @RequiresPermissions("operinfo:oper_info:remove")
    @Log(title = "操作员信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(aOperInfoService.deleteAOperInfoByIds(ids));
    }
}
